﻿

//
function setSkinToCookie(key, value) {
    $.cookie("'" + key + "'", value); // 设置/新建cookie的值   
}
//从cookie 加载皮肤
function getSkinFromCookie(key) {
    var skin = $.cookie("'" + key + "'"); //读取Cookie值 
    if (skin == null)
        skin = defaultSkin;
 
    return skin;
}

 
//获取当前用户的主页布局
function getCurrentUserHomePageLayout() {
    return defaultLayout;
    // return $("hf_UserHomePageLayout").val();
    var fromServer = $("#hf_UserHomePageLayout").val();

    if (fromServer == "") {
        return defaultLayout;
    }
    return fromServer;
    try {
        var key = $("#hf_SkinName").val() + ".homePageLayout";
        var value = getDataFromCookieOrDefaultskin(key, defaultLayout);
        // alert(value);
        var arr = value.split(']');
        var result = new Array();
        //  alert(arr);
        $(arr).each(function (a, aa) {
            var info = aa.split('[');  // ,item3,item4 / ,item2/ ,item11  ---> take [1],[2]   

            $(info).each(function (i, ii) {
                var item = ii.split(','); // [1],[2] ,
                //alert(item);
                if (item.length == 2) {
                    //alert("item[1]:" + item[0]);
                    result.push([item[0], item[1]]);
                }
                else if (item != "") {
                    result.push([item[0], "item" + (i + 1) + a]);
                }
            });

        });

        if (result.length < 6)
            result.push(["item23", "item24"]);
        return result;
    } catch (e) {
        return defaultLayout;
    }

}

//
function getDataFromCookieOrDefaultskin(key, defValueIfNull) {
    var skin = $.cookie("'" + key + "'"); //读取Cookie值 
    if (skin == null)
        skin = defValueIfNull;

    return skin;
}

function loadChildSkinFromCookie()
{
	var skin_name = getDataFromCookieOrDefaultskin("skinFor_","blue");
	//alert(skin_name);
    var child = "themes/css/ui.c." + skin_name + ".css";
    var childSkinObject =  document.getElementById("skin_css");
    if (childSkinObject != undefined)
        childSkinObject.href = child;
    else {
        	
        	 
        }
}  

function getParentSkinName()
{
	 return  getDataFromCookieOrDefaultskin("SkinFor_","blue");
}

$(function(){
	
	//loadChildSkinFromCookie();
	
});